package com.cet.regularexpression;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-06-21 22:46
 **/
public class Main07 {

    private static Pattern PHONE_NUMBER =  Pattern.compile("(\\d{3,4})-(\\d{7,8})");

    public static void main(String[] args) {
        Matcher m = PHONE_NUMBER.matcher("010-12345678");
        if (m.matches()) {
            String g1 = m.group(1);
            String g2 = m.group(2);
            System.out.println(g1);
            System.out.println(g2);
        } else {
            System.out.println("匹配失败!");
        }
    }
}
